#ifndef WIN32
#include <arpa/inet.h>
#else
#include <Winsock2.h>
#endif
#include "msg_encoder.h"
#include "msg_decoder.h"

namespace herm{

DefHdrEncoder::DefHdrEncoder(char* buf, int len, uint16_t type, uint16_t code)
	: Encoder(buf, len)
{
	uint32_t length = 5;
	uint8_t ver = 0;
	*this << length << ver << type << code; 
}

DefHdrEncoder::DefHdrEncoder(char* buf, int len) : Encoder(buf, len)
{
}

void DefHdrEncoder::Version(uint8_t ver)
{
	EncodeBuf(2, &ver, sizeof(uint8_t));
}

DefHdrDecoder::DefHdrDecoder(const char* buf, int len)
	: Decoder(buf, len)
{
	*this >> m_len >> m_ver >> m_type >> m_code;
}
}
